from django.db import models


# 商城商品菜单模型
class Feedback(models.Model):
    id = models.AutoField(primary_key=True)
    # 反馈人
    back_user_id = models.IntegerField(default=0)
    # 反馈内容
    back_text = models.TextField(null=True)
    # 回复内容
    reply = models.TextField(null=True)
    # 回复内容是否已读
    read = models.BooleanField(default=True)

    def to_dict(self):
        res = {
            "id": self.id,
            "back_user_id": self.back_user_id,
            "back_text": self.back_text,
            "reply": self.reply,
            "read": self.read
        }
        return res

    @staticmethod
    def get_fields():
        return [
            {"field": "id", "remark": "ID"},
            {"field": "back_user_id", "remark": "反馈人", "is_query": "1"},
            {"field": "back_text", "remark": "反馈内容"},
            {"field": "reply", "remark": "回复内容"},
#             {"field": "read", "remark": "回复内容是否已读"},
        ]

    class Meta:
        db_table = "feedback"
        app_label = "models"
